package javaMultiThread;
/**
 * java多线程编程艺术第一章
 * @author jieji
 *
 */
/**
 * 
 * @author jieji
 *
 */
public class Thread1 {

	public static void main(String[] args) {
		ThreadGroup tg=new ThreadGroup("threadGroup");
		A1 a1=new A1();
		a1.start();
		t1(a1);
		a1.getThreadGroup();
	}
	/*interupted是指运行这个方法的线程,这个方法是main运行的,所以返回的是false
	 *如果要返回true,则必须要拿到此当前线程,然后调用interrupt方法
	 *interrupted具有清楚状态的功能,也就是说如果线程已经停止,第一次调用返回true,第二次则返回false
	 */
	/*
	 * isInterrupted方法是判断此线程是否关闭
	 */
	public static void t1(A1 a1){
		a1.interrupt();
		System.out.println(a1.isInterrupted()+"==a1.interrupt()后a1线程isInterrupted");
		Thread.currentThread().interrupt();
		System.out.println(Thread.interrupted()+"==调用当前线程的interrupted");
		System.out.println(Thread.interrupted()+"==调用当前线程的interrupted");
		System.out.println(Thread.interrupted()+"==调用当前线程的interrupted");
		System.out.println(Thread.currentThread().isInterrupted()+"==isInterrupted");
	}
	/**
	 * stop方法会强制对锁定对象进行解锁导致数据不同步,暴力停止
	 * suspend暂停
	 * resume恢复
	 * yield放弃当前cpu资源
	 * setPriority设置优先级(优先级具有继承性)
	 * setDaemon设置是否为守护线程ture为是 false不是
	 * 
	 * 
	 */
	public static void t2(){
		
	}

}
class A1 extends Thread{
	public A1(){
		super("a1");
		System.out.println(Thread.currentThread().getName()+"A1构造方法");
	}

	@Override
	public void run() {
		
		super.run();
		System.out.println(Thread.currentThread().getName()+"A1");
	}
}
